<template>
  <div>
    <template v-for="(item, index) in options">
      <template v-if="values.includes(item[props.value])">
        <span v-if="item.listClass == 'default' || item.listClass == ''" :key="item[props.value]" :index="index" :class="item.listClass">{{ item[props.label] }}</span>
        <el-tag v-else :disable-transitions="true" :key="item[props.value] + ''" :index="index" :type="item.listClass === 'primary' ? '' : item.listClass" :class="item.listClass">{{ item[props.label] }}</el-tag>
      </template>
    </template>
  </div>
</template>

<script>
import config from "@/utils/dict"

export default {
  name: "DictTag",
  mounted() {},
  props: {
    options: {
      type: Array,
      default: null
    },
    value: [Number, String, Array]
  },
  data() {
    return {
      props: config.props
    }
  },
  computed: {
    values() {
      if (this.value !== null && typeof this.value !== "undefined") {
        return Array.isArray(this.value) ? this.value : [String(this.value)]
      } else {
        return []
      }
    }
  }
}
</script>

<style scoped>
.el-tag + .el-tag {
  margin-left: 10px;
}
</style>
